Skip to content

Conversation

jrmuizel
Copy link
Contributor

@jrmuizel jrmuizel commented May 26, 2021

This ends up disabling frame pointer elimination on aarch64_apple_darwin
which matches what clang does by default along with the
aarch64_apple_ios and x86_64_apple_darwin targets.

Further, the Apple docs "Writing ARM64 Code for Apple Platforms" has a section
called "Respect the Purpose of Specific CPU Registers" which
specifically calls out the frame pointer register (x29):

The frame pointer register (x29) must always address a valid frame
record. Some functions — such as leaf functions or tail calls — may
opt not to create an entry in this list As a result, stack traces
are always meaningful, even without debug information.

Other platforms are updated to not override the default.

@rust-highfive
Copy link
Contributor

r? @matthewjasper

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 26, 2021
@jrmuizel
Copy link
Contributor Author

This should also fix profiling rust code on the M1 in Instruments.

@mstange
Copy link

mstange commented May 28, 2021

r? @shepmaster

I'd like to emphasize the importance of this change: Without this, profiles taken with Instruments are basically useless. And there is no workaround.

The Apple docs Writing ARM64 Code for Apple Platforms has a section called "Respect the Purpose of Specific CPU Registers" which specifically calls out the frame pointer register (x29):

The frame pointer register (x29) must always address a valid frame record. Some functions — such as leaf functions or tail calls — may opt not to create an entry in this list As a result, stack traces are always meaningful, even without debug information.

@nagisa
Copy link
Member

nagisa commented Jun 2, 2021

Please remove the now-unnecessary override from the specific targets (such as aarch64_apple_ios).

It would be nice, also, if you could incorporate the information from the comment above into the original PR description so that it ends up in the merge commit.

r=me once these are done.

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned matthewjasper Jun 2, 2021
This ends up disabling frame pointer elimination on aarch64_apple_darwin
which matches what clang does by default along with the
aarch64_apple_ios and x86_64_apple_darwin targets.

Further, the Apple docs "Writing ARM64 Code for Apple Platforms" has a section
called "Respect the Purpose of Specific CPU Registers" which
specifically calls out the frame pointer register (x29):

   The frame pointer register (x29) must always address a valid frame
   record. Some functions — such as leaf functions or tail calls — may
   opt not to create an entry in this list As a result, stack traces
   are always meaningful, even without debug information.

Other platforms are updated to not override the default.
@jrmuizel jrmuizel changed the title Turn off frame pointer elimination on aarch64_apple_darwin. Turn off frame pointer elimination on all Apple platforms. Jun 2, 2021
@nagisa
Copy link
Member

nagisa commented Jun 2, 2021

@bors r+ thanks!

@bors
Copy link
Collaborator

bors commented Jun 2, 2021

📌 Commit aab8545 has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 2, 2021
@ghost
Copy link

ghost commented Jun 3, 2021

@mstange
Copy link

mstange commented Jun 3, 2021

Oh, neat!

(Edit for future me: One way to use it is RUSTFLAGS="-C force-frame-pointers=yes" cargo build --release)

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 3, 2021
Rollup of 13 pull requests

Successful merges:

 - rust-lang#83362 (Stabilize `vecdeque_binary_search`)
 - rust-lang#85706 (Turn off frame pointer elimination on all Apple platforms. )
 - rust-lang#85724 (Fix issue 85435 by restricting Fake Read precision)
 - rust-lang#85852 (Clarify meaning of MachineApplicable suggestions.)
 - rust-lang#85877 (Intra doc link-ify a reference to a function)
 - rust-lang#85880 (convert assertion on rvalue::threadlocalref to delay bug)
 - rust-lang#85896 (Add test for forward declared const param defaults)
 - rust-lang#85897 (Update I-unsound label for triagebot)
 - rust-lang#85900 (Use pattern matching instead of checking lengths explicitly)
 - rust-lang#85911 (Avoid a clone of output_filenames.)
 - rust-lang#85926 (Update cargo)
 - rust-lang#85934 (Add `Ty::is_union` predicate)
 - rust-lang#85935 (Validate type of locals used as indices)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9b1e105 into rust-lang:master Jun 3, 2021
@rustbot rustbot added this to the 1.54.0 milestone Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants